//167.两数之和Ⅱ-输入有序数组
//https://leetcode.cn/problems/two-sum-ii-input-array-is-sorted
class Solution {
public:
    vector<int> twoSum(vector<int>& numbers, int target) {
        int n = numbers.size();

        for(int i = 0;i<n;++i)
        {
            int num = target-numbers[i];
            int l = i+1,r = n-1;
            while(l <= r)
            {
                int mid = (l+r)/2;
                if(numbers[mid] > num) r = mid-1;
                else if(numbers[mid] < num) l = mid+1;
                else return {i+1,mid+1};
            }
        }
        return {-1,-1};
    }
};